﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.ComponentModel;
using System.Xml.Linq;
using System.IO;
using ComApp.Model;

namespace ComApp
{
    public interface IServerDeploy
    {
        string WebServerHostName{get;}
        string WcfSystemUrl{get;}
        string WcfTempFileUrl { get; }
        string WebUploadFileUrl { get; }
    }

    public class ServerDeployXml : IServerDeploy
    {
        public ServerDeployXml(string serverDeployXmlFile)
        {
            this.serverDeployXml = XElement.Load(serverDeployXmlFile);
        }

        private XElement serverDeployXml;
        public string WebServerHostName
        {
            get { return serverDeployXml.Element("WebServerHostName").Value; }
        }

        public string WcfSystemUrl
        {
            get
            {
                return string.Format("http://{0}/WcfService/WcfSystemService.svc", this.WebServerHostName);
            }
        }

        public string WcfTempFileUrl
        {
            get
            {
                return string.Format("http://{0}/WcfService/WcfTempFileService.svc", this.WebServerHostName);
            }
        }

        public string WebUploadFileUrl
        {
            get
            {
                return string.Format("http://{0}/Default/File/Upload", this.WebServerHostName);
            }
        }
    }

    public class ServerDeploy:IServerDeploy
    {
        public string WebServerHostName
        {
            get { return "siai.org"; }
            //get { return "localhost:2013"; }
        }

        public string WcfSystemUrl
        {
            get
            {
                return string.Format("http://{0}/WcfService/WcfSystemService.svc", this.WebServerHostName);
            }
        }

        public string WcfTempFileUrl
        {
            get
            {
                return string.Format("http://{0}/WcfService/WcfTempFileService.svc", this.WebServerHostName);
            }
        }

        public string WebUploadFileUrl
        {
            get
            {
                return string.Format("http://{0}/Default/File/Upload", this.WebServerHostName);
            }
        }

    }
}
